<template>
  <div style="height: 1000px">
    <div class="hero_bg"></div>
    <div class="w">
      <div class="d-flex flex-row user-header justify-content-between">
        <!-- 用户ID -->
        <div class="col-4 uid">
          <span>UID:332793</span>
          <a href="#">举报</a>
        </div>
        <!-- 用户头像 -->
        <div class="avatar">
          <div>
            <img class="rounded-pill" :src="authorInfo.pic2" alt="" />
          </div>
        </div>
        <!-- 用户关注 -->
        <div class="col-4 focus d-flex justify-content-end align-items-start">
          <div class="rounded">
            <i class="fa fa-envelope-o" aria-hidden="true"></i>
            <span>工作联系</span>
          </div>
        </div>
      </div>
      <div class="d-flex flex-row justify-content-center name">
        <h2 class="">{{ authorInfo.name }}</h2>
      </div>
      <div class="d-flex flex-column justify-content-center">
        <div class="d-flex justify-content-center token">
          <p>王国推荐作者</p>
          <p>插画师</p>
        </div>
        <div class="d-flex justify-content-center signedbox">
          <p>{{ authorInfo.desc }}</p>
        </div>
        <div class="d-flex flex-row justify-content-center">
          <ul class="d-flex justify-content-between list">
            <li class="d-flex flex-column">
              <h6>138</h6>
              <p>作品</p>
            </li>
            <li class="d-flex flex-column">
              <h6>{{ authorInfo.pop }}</h6>
              <p>人气</p>
            </li>
            <li class="d-flex flex-column">
              <h6>{{authorInfo.focus}}</h6>
              <p>关注</p>
            </li>
            <li class="d-flex flex-column">
              <h6>{{authorInfo.fans}}</h6>
              <p>粉丝</p>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="bg-white shadow-sm">
      <div class="w">
        <ul class="d-flex justify-content-center navs">
          <li
            :class="index == 1 ? 'active' : ''"
            @click="changNav(1, 'compUserWorks')"
          >
            作品
          </li>
          <li
            :class="index == 2 ? 'active' : ''"
            @click="changNav(2, 'CompUserHonors')"
          >
            荣誉榜
          </li>
          <li
            :class="index == 3 ? 'active' : ''"
            @click="changNav(3, 'CompUserMaterial')"
          >
            资料
          </li>
        </ul>
      </div>
    </div>
    <div class="user-body">
      <div class="w">
        <component :is="comp"></component>
      </div>
    </div>
  </div>
</template>

<script>
import CompUserHonors from "../components/comp-user-honors.vue";
import CompUserMaterial from "../components/comp-user-material.vue";
import compUserWorks from "../components/comp-user-works.vue";

import { mapState } from "vuex";

export default {
  components: { compUserWorks, CompUserHonors, CompUserMaterial },
  data() {
    return {
      comp: compUserWorks,
      index: 1,
      authorInfo: null,
    };
  },
  computed: {
    ...mapState(["userModule"]),
  },
  methods: {
    changNav(i, name) {
      this.index = i;
      this.comp = name;
    },
  },
  created() {
    let id = this.$route.query.id;
    let authorInfo = this.userModule.artist.filter((item) => {
      if (item.aid == id) {
        return true;
      } else {
        return false;
      }
    });
    this.authorInfo = authorInfo[0];
  },
};
</script>

<style lang="less" scoped>
@import "../assets/reset";
.hero_bg {
  width: 100%;
  height: 200px;

  background-image: url(https://qiniucssjs.gracg.com/bg2.jpg);
  background-size: cover;
  background-position: center;
}
.user-header {
  height: 80px;
  .avatar {
    > div {
      width: 120px;

      img {
        width: 120px;
        margin-top: -60px;
      }
    }
  }
  .uid,
  .focus {
    padding-top: 15px;
    font-size: 13px;
  }
  .uid {
    color: #999;
    span {
      margin-right: 13px;
    }
    a {
      color: #999;
    }
  }
  .focus {
    > div {
      border: 1px solid #000;
      padding: 4px 10px;
      span {
      }
    }
  }
}
.name {
  h2 {
    font-weight: bold;
    height: 40px;
  }
}
.token {
  padding: 20px 0;
  p {
    padding-left: 22px;

    background-size: 18px;
    background-position: left center;
    background-repeat: no-repeat;
    &:nth-child(1) {
      background-image: url(http://www.gracg.com/_templates/css/icon_rz/star.png?);
    }
    &:nth-child(2) {
      background-image: url(http://www.gracg.com/_templates/css/icon_rz/red_v.png?1);
    }
  }
}
.signedbox {
  .pseudo {
    content: "";
    display: block;
    width: 20px;
    height: 20px;
    background-size: cover;
    margin: 0 20px;
  }
  p {
    display: flex;

    &::before {
      .pseudo();
      background-image: url(http://www.gracg.com/_templates/css/icon_rz/yh_l.png);
    }
    &::after {
      .pseudo();
      background-image: url(http://www.gracg.com/_templates/css/icon_rz/yh_r.png);
    }
  }
}
.list {
  padding: 20px 0;
  li {
    margin: 0 40px;
    h6 {
      font-weight: bold;
    }
    p {
      font-size: 12px;
      color: #999;
      text-align: center;
    }
  }
}
.navs {
  li {
    width: 200px;
    text-align: center;
    padding: 10px 30px;
    color: #888;
    font-size: 15px;
    cursor: pointer;
  }
  .active {
    font-weight: bold;
    border-bottom: 2px solid #000;
  }
}
</style>